<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('订单发货明细列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <input id="mid" name="mid" th:value="${mid}" type="hidden">
            <!--<div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>-订单明细表SOS中的自增ID：</label>
                                <input type="text" name="ids"/>
                            </li>
                            <li>
                                <label>订单明细表SOS中的pcode：</label>
                                <input type="text" name="pcode"/>
                            </li>
                            <li>
                                <label>订单明细表SOS中的pname：</label>
                                <input type="text" name="pname"/>
                            </li>
                            <li>
                                <label>订单明细表SOS中的pstd：</label>
                                <input type="text" name="pstd"/>
                            </li>
                            <li>
                                <label>发货数量：</label>
                                <input type="text" name="sendqty"/>
                            </li>
                            <li>
                                <label>发货物流号：</label>
                                <input type="text" name="logcode"/>
                            </li>
                            <li>
                                <label>备注：</label>
                                <input type="text" name="smemo"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>-->

           <!-- <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="erp:sossend:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="erp:sossend:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="erp:sossend:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="erp:sossend:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>-->
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <th:block th:include="include :: bootstrap-table-editable-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('erp:sossend:edit')}]];
        var removeFlag = [[${@permission.hasPermi('erp:sossend:remove')}]];
        var prefix = ctx + "erp/sossend";
        var mid = $("#mid").val();
        $(function() {
            var options = {
                url: prefix + "/list?mid="+mid,
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                modalName: "订单发货信息",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                showPageGo: true,
                columns: [{
                    checkbox: true
                }
                    ,
                    {
                        field: 'idsos',
                        title: 'sos编号',
                        visible:false
                    },
                    {
                        field: 'kingst',
                        title: '生单状态',
                        visible:false
                    },
                    {
                        field: 'itemcode',
                        title: '金蝶编码'
                    },
                {
                    field: 'pcode', 
                    title: '产品编码'
                },
                {
                    field: 'pname', 
                    title: '产品名称'
                },
                {
                    field: 'pstd', 
                    title: '产品规格'
                },
                {
                    field: 'sendqty', 
                    title: '发货数量'
                },
                {
                    field: 'logcode', 
                    title: '发货物流号'
                },
                    {
                        field: 'fromwhname',
                        title: '发货仓库'
                    }
                    ,
                    {
                        field: 'isreplace',
                        title: '是否厂家代发'
                    }
                    ,
                    {
                        field: 'sendcode',
                        title: '发货号'
                    },
                    {
                        field: 'senddt',
                        title: '发货日期'
                    },
                    {
                        field: 'recemp',
                        title: '收货账号'
                    },
                    {
                        field: 'smemo',
                        title: '收货备注'
                    }
                    ,
                    {
                        field: 'recdt',
                        title: '收货日期'
                    },
                    {
                        field: 'st',
                        title: '发货状态'
                    },
                    {
                        field: 'smemo',
                        title: '发货备注'
                    },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.st == '发货'){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }
                        if(row.st == '收货'){
                            if(row.kingst == '0'){
                                actions.push('<a class="btn btn-warning btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="updateJDinfo(\'' + row.sendcode + '\')"><i class="fa fa-warning"></i>生单</a>');
                            }
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        /* 添加用户-选择用户-提交 */
        function submitHandler() {
            $.modal.reload();
        }
        
        function updateJDinfo(sendcode) {
            $.ajax({
                type: "post",
                url: ctx + "erp/so/updateJDinfo?type=1&id="+sendcode,
                success: function(r) {
                    $.modal.msgSuccess("生单成功");
                }
            });
            $.modal.reload();
        }
    </script>
</body>
</html>